package com.itheima01;

import javax.xml.namespace.QName;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;

public class Test03 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchFieldException {

        Class clazz = Class.forName("com.itheima01.Student");

        Student stu = (Student) clazz.getDeclaredConstructor().newInstance();

        Field declaredField = clazz.getDeclaredField("name");
        declaredField.setAccessible(true);

        declaredField.set(stu, "zhangsan");

        Object o = declaredField.get(stu);

        System.out.println(o);
        System.out.println(stu);

    }
}
